<include file="Public/header"/>
<body class="body-bg">
<div class="park-header">
    <div class="park-header__title">优惠券</div>
    <div class="park-header__left" onclick="window.location='/Home/User/index';">
        <i class="iconfont icon-fanhui"></i>
    </div>
</div>
<div class="park-coupon-header">
    <ul class="park-coupon-tabs">
        <li onclick="window.location='/Home/User/coupon/type_id/1';" <if condition="$type_id eq 1">class="active"</if>>未使用</li>
        <li onclick="window.location='/Home/User/coupon/type_id/2';" <if condition="$type_id eq 2">class="active"</if>>已使用</li>
        <li onclick="window.location='/Home/User/coupon/type_id/3';" <if condition="$type_id eq 3">class="active"</if>>已过期</li>
    </ul>
</div>
<div class="container">
    <div class="park-coupon-list" id="goods_list">
    </div>
</div>
<script>
    var options = {
        type: 'get', // default 'get'
        dataType: 'html' // default 'json'
    };
    $(function () {
        var url = '/Home/User/coupon/';
        var type_id = '{$type_id}';
        var params = {'act':'ajax','type_id':type_id};
        PARK.dropLoad(PARK.dropAjax(options, url, params, function (data) {
            var data = JSON.parse(data);
            var html = '';
            for (var i = 0; i < data.result.length; i++) {
                html += '<div class="park-coupon-item">';
                if (type_id<3){
                    html += '    <div class="park-coupon-info park-coupon-info--1">';
                }else{
                    html += '    <div class="park-coupon-info park-coupon-info--0">';
                }
                html+='        <span class="price">￥<b>'+data['result'][i]['coupon_price']+'</b></span>';
                html+='        <span class="price-max">'+data['result'][i]['title']+'</span>';
                if (type_id==2){
                    html+='        <div class="stamp-icon stamp-icon--0"></div>';
                }else if (type_id==3){
                    html+='        <div class="stamp-icon stamp-icon--1"></div>';
                }
                html+='    </div>';
                html+='    <div class="park-coupon-footer">';
                html+='        <span>有效期:&nbsp;'+data['result'][i]['add_time']+'</span>';
                html+='        <span>全场通用</span>';
                html+='    </div>';
                html+='</div>';
            }
            if(html){
                $('#goods_list').append(html);
            }else {
                $('#goods_list').append('<div style="text-align:center;padding:50px;color:#ccc;">暂无优惠券</div>');
            }
            if(data.is_page==1){
                PARK.unDropLoad();
            }
        }));
        $(document).on('click', '.park-coupon-tabs li',function () {
            $('.park-coupon-tabs li').removeClass('active');
            $(this).addClass('active');
        });
    });
</script>
</body>
</html>